<?php
namespace Api\Event;

/**
 * showgirl
 * @author liubo <liubo@ilongyuan.com.cn>
 */
class ShowgirlEvent extends BaseEvent
{

    public function lists($filter = [], $field = '', $p = 1, $limit = 10)
    {
        $map = ['status' => 1];
        $filter && $map = array_merge($map, $filter);
        !$field && $field = 'id,name,description,avatar,user_id';
        $query = service('Showgirl')->where($map)->order('sort asc');
        if ($p && $limit) {
            $query->page($p)->limit($limit);
        }
        $res = $query->field($field)->select();
        $list = [];
        if ($res) {
            foreach ($res as $value) {
                uri_format($value['avatar']);
                $list[] = $value;
            }
        }
        return $list;
    }
}